<?php

namespace App\Repository\Redis;


use App\DataStore\RedisGeneral;
use App\Model\Divistion\DivisionModel;
use App\Repository\RepositoryGeneral;
use Hyperf\Di\Annotation\Inject;

class DivisionRedis extends RepositoryGeneral
{
    #[Inject]
    public DivisionModel $divisionModel;

    public function getDivisions(){
        return jsonDecode(RedisGeneral::getInc()->getOrganDivision(getOrganIdByOrganCode()));
    }

    public function updateDivisions(){
        $data = $this->divisionModel->withCustomCondition()
            ->get()
            ->toArray();
        RedisGeneral::getInc()->setOrganDivision(getOrganIdByOrganCode(),$data);
    }
}